package edu.sctu.xialei.May.day20150527one;

import java.util.Scanner;

/**
 * Created by Administrator on 5/27/2015.
 */
public class Student {
    String name;
    int number;
    String sex;
    StudentCard studentCard;
    Seat seat;

//    学生选择窗口
    public DishesWindow chooseWindow(DiningRoom diningRoom){
        System.out.println("\n");
        System.out.println("有三个窗口，编号是：1 , 2 , 3");
        System.out.println("请输入你要选择的窗口编号： ");

        Scanner inputNumber = new Scanner(System.in);

        int choice = inputNumber.nextInt();

        DishesWindow dishesWindow = null;

        switch (choice){
            case  1: dishesWindow = diningRoom.dishesWindows[0];break;
            case  2: dishesWindow = diningRoom.dishesWindows[1];break;
            case  3: dishesWindow = diningRoom.dishesWindows[2];break;
        }

        System.out.println("现在这个窗口有 " + dishesWindow.nowLinePepoleNuber + " 个人排队");

        return dishesWindow;
    }

//    学生选择菜品和米饭
    public float chooseDishes(DishesWindow dishesWindow){

        Scanner input = new Scanner(System.in);

        System.out.println("\n\n此窗口的菜品有：");
        System.out.println(dishesWindow.dishes.keySet());

        String dishName = null;
        for (String check = "no";check.equals("yes") != true; check = input.next()) {
            System.out.println("输入 菜名 查看该菜品：");
            dishName  = input.next();
            System.out.println("菜色：" + dishesWindow.dishes.get(dishName).color + "     菜的价格："
                    + dishesWindow.dishes.get(dishName).price);
            System.out.println("输入 yes 或者 no 确定选择");
        }

        System.out.println("你需要几两米饭，单价 0.5 元：");

        return (input.nextFloat() * dishesWindow.rice.price + dishesWindow.dishes.get(dishName).price);
    }

//    学生刷卡
    public void payForDish(float totalMoney ){
        studentCard.money = studentCard.money - totalMoney;
    }

//    学生选择座位

    public void chooseSeat(DiningRoom diningRoom) {
        Scanner input = new Scanner(System.in);

        System.out.println("\n\n");

        System.out.println("有 20 个座位，编号是 1 到 20 ， 选择一个座位：");

        for (int i = 0; i < 20; i++) {
            int choice = input.nextInt();
            if (diningRoom.seats[choice - 1].statement == 1) {
                System.out.println("这个座位已经有人坐了，换个位置吧：");
            } else {
                System.out.println("这个座位没人，可以坐");
                seat = diningRoom.seats[choice - 1];
                break;
            }
        }
    }
}
